#!/bin/sh /etc/rc.common
# Created By ImmortalWrt
# https://github.com/project-openwrt

START=99
STOP=10

USE_PROCD=1

enable="$(uci get gost.@gost[0].enable)"
run_command="$(uci get gost.@gost[0].run_command)"

start_service() {
	[ "${enable}" -ne "1" ] && exit 0
	procd_open_instance gost
	procd_set_param command /usr/bin/gost
	procd_append_param command ${run_command}

	procd_set_param respawn ${respawn_threshold:-3600} ${respawn_timeout:-5} ${respawn_retry:-5}

	procd_set_param limits core="unlimited"
	procd_set_param stdout 1
	procd_set_param stderr 1
	procd_close_instance
}

reload_service()
{
	stop
	start
}

service_triggers()
{
	procd_add_reload_trigger "gost"
}
